Skip to content

Add --json output flag to brotab list#113

Open
pschmitt wants to merge 2 commits intobalta2ar:masterfrom
pschmitt:json-output
Open

Add --json output flag to brotab list#113
pschmitt wants to merge 2 commits intobalta2ar:masterfrom
pschmitt:json-output

Conversation

@pschmitt
Copy link

@pschmitt pschmitt commented Dec 19, 2023

This adds a --json flag to brotab list.

The output format looks like this:

[{"id": "a.1.186","title": "Add --json output flag to brotab list by pschmitt · Pull Request #113 · balta2ar/brotab","url": "https://github.com/balta2ar/brotab/pull/113"}]

@jackmac92
Copy link

jackmac92 commented Oct 8, 2024

Was hoping I'd find an open issue/PR re: json output. I'd find it really useful
is this something you're interested in @balta2ar ?

edit: using this for now

brotab list |
  # Converts each line of tab delimited output to a JSON list
  awk -F'\t' '{
   printf "[";
    for(i=1; i<=NF; i++) {
      printf "%s\"%s\"", (i>1 ? "," : ""), $i
    }
   print "]"
  }' |
  # Creates an object to add labels
  jq -c '{ id: .[0], title: .[1], url: .[2] }'

@pyhedgehog
Copy link

pyhedgehog commented Mar 18, 2025

@pschmitt It's good start for #124, but I'm sure that to continue we need support from plugin/addon backend. ;-(
@jackmac92
It can be done much easier:

brotab list | \
  jq -Rc 'split("\t")|with_entries(.key|=["id","title","url"][.])'

@jackmac92
Copy link

@pschmitt It's good start for #124, but I'm sure that to continue we need support from plugin/addon backend. ;-( @jackmac92 It can be done much easier:

brotab list | \
  jq -Rc 'split("\t")|with_entries(.key|=["id","title","url"][.])'

thanks!! mine was running into some issues with special chars, this looks much better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants